///Project: PoP GLP Paper Table 6
///Stata14 

********TABLE 6*************

***Row 1: Tenure***
clear all
use "GLP_person_18 07 29.dta"
drop if person_office_start_year==0
drop if person_office_start_year>2013
drop if person_office_start_year<1955
gen tenure=2013-person_office_start_year
preserve
count
sort country_nid
collapse (mean) tenure=tenure, by(country country_nid)
sum tenure
restore
*Apex*
preserve
keep if power==1
collapse (mean) tenure=tenure, by(country country_nid)
sum tenure
restore
*Next 10*
preserve
keep if power==3
collapse (mean) tenure=tenure, by(country country_nid)
sum tenure
restore
*Cabinet*
preserve
keep if office1==2|office2==2|office3==2
collapse (mean) tenure=tenure, by(country country_nid)
sum tenure
restore
*Supreme Supreme Court*
preserve
keep if office1==7|office2==7|office2==7
collapse (mean) tenure=tenure, by(country country_nid)
sum tenure
restore
*MPs*
preserve
keep if office1==6|office2==6|office2==6
collapse (mean) tenure=tenure, by(country country_nid)
sum tenure
restore
*Wealth*
preserve
keep if wealth==0
collapse (mean) tenure=tenure, by(country country_nid)
sum tenure
restore

preserve
keep if wealth==1
collapse (mean) tenure=tenure, by(country country_nid)
sum tenure
restore
*Regime*
*Demo
preserve
keep if regime==0
collapse (mean) tenure=tenure, by(country country_nid)
sum tenure
restore
*auto
preserve
keep if regime==1
collapse (mean) tenure=tenure, by(country country_nid)
sum tenure
restore
//regions
preserve
collapse (mean) tenure=tenure, by( region country_nid)
by region, sort: sum tenure
restore


***Rows Experience 8***
//1	None
//2	Trade union (national, supra-national)
//3	Employer’s organization (national, supra-national)
//4	Interest group (national, supra-national)
//5	NGO/Political movement/Governmental intl org
//6	Local gov/Municipal position
//7	Partisan
//8	Previous MP/Minister
clear all
use "GLP_person_18 07 29.dta"
drop if missing(polexp)
count
tab polexp
count
count if power==1
count if power==3
count if office1==2|office2==2|office3==2
count if office1==7|office2==7|office3==7
count if office1==6|office2==6|office3==6
count if wealth==0
count if wealth==1
count if region==1
count if region==2
count if region==3
count if region==4
count if region==5
count if regime==0
count if regime==1
**None**
preserve
gen temp=1
sort country_nid
by country_nid: egen none=total(temp) if polexp==1
by country_nid: egen allexp=total(temp)
gen percentage=none/allexp*100
keep if none<.
duplicates drop country_nid, force
merge m:1 country_nid using  "Country_list.dta" 
replace percentage=0 if _merge==2
sum percentage
return list
sum percentage if wealth==1
sum percentage if wealth==0
sum percentage if regime==0
sum percentage if regime==1
by region, sort: sum percentage
restore
*Apex* 
preserve
keep if power==1
count
gen temp=1
sort country_nid
by country_nid: egen none=total(temp) if polexp==1
by country_nid: egen allexp=total(temp)
gen percentage=none/allexp*100
replace percentage=0 if missing(percentage)
collapse (max) percentage, by(country_nid)
sum percentage
restore
*Top ten*
preserve
keep if power==3
count
gen temp=1
sort country_nid
by country_nid: egen none=total(temp) if polexp==1
by country_nid: egen allexp=total(temp)
gen percentage=none/allexp*100
replace percentage=0 if missing(percentage)
collapse (max) percentage, by(country_nid)
sum percentage
restore
*Cabinet*
preserve
keep if office1==2 |office2==2 |office3==2
count
gen temp=1
sort country_nid
by country_nid: egen none=total(temp) if polexp==1
by country_nid: egen allexp=total(temp)
gen percentage=none/allexp*100
replace percentage=0 if missing(percentage)
collapse (max) percentage, by(country_nid)
sum percentage
restore
*Supreme Court*
preserve
keep if office1==7 |office2==7 |office3==7 
count
gen temp=1
sort country_nid
by country_nid: egen none=total(temp) if polexp==1
by country_nid: egen allexp=total(temp)
gen percentage=none/allexp*100
replace percentage=0 if missing(percentage)
collapse (max) percentage, by(country_nid)
sum percentage
restore
*MPs*
preserve
keep if office1==6 |office2==6 |office3==6
count
gen temp=1
sort country_nid
by country_nid: egen none=total(temp) if polexp==1
by country_nid: egen allexp=total(temp)
gen percentage=none/allexp*100
replace percentage=0 if missing(percentage)
collapse (max) percentage, by(country_nid)
sum percentage
restore
/////////////////////////////////////////////////////
**Trade Union**
preserve
drop if missing(polexp)
gen temp=1
sort country_nid
by country_nid: egen trade=total(temp) if polexp==2
by country_nid: egen allexp=total(temp)
gen percentage=trade/allexp*100
keep if trade<.
duplicates drop country_nid, force
merge m:1 country_nid using  "Country_list.dta"
replace percentage=0 if _merge==2
sum percentage
return list
sum percentage if wealth==1
sum percentage if wealth==0
sum percentage if regime==0
sum percentage if regime==1
by region, sort: sum percentage
restore
*Apex* 
preserve
keep if power==1
gen temp=1
sort country_nid
by country_nid: egen trade=total(temp) if polexp==2
by country_nid: egen allexp=total(temp)
gen percentage=trade/allexp*100
replace percentage=0 if missing(percentage) 
collapse (max) percentage, by(country_nid)
sum percentage
restore
*Top ten*
preserve
keep if power==3
gen temp=1
sort country_nid
by country_nid: egen trade=total(temp) if polexp==2
by country_nid: egen allexp=total(temp)
gen percentage=trade/allexp*100
replace percentage=0 if missing(percentage) 
collapse (max) percentage, by(country_nid)
sum percentage
restore
*Cabinet*
preserve
keep if office1==2 |office2==2 |office3==2
gen temp=1
sort country_nid
by country_nid: egen trade=total(temp) if polexp==2
by country_nid: egen allexp=total(temp)
gen percentage=trade/allexp*100
replace percentage=0 if missing(percentage) 
collapse (max) percentage, by(country_nid)
sum percentage
restore
*Supreme Court*
preserve
keep if office1==7 |office2==7 |office3==7 
gen temp=1
sort country_nid
by country_nid: egen trade=total(temp) if polexp==2
by country_nid: egen allexp=total(temp)
gen percentage=trade/allexp*100
replace percentage=0 if missing(percentage) 
collapse (max) percentage, by(country_nid)
sum percentage
restore
*MPs*
preserve
keep if office1==6 |office2==6 |office3==6
gen temp=1
sort country_nid
by country_nid: egen trade=total(temp) if polexp==2
by country_nid: egen allexp=total(temp)
gen percentage=trade/allexp*100
replace percentage=0 if missing(percentage) 
collapse (max) percentage, by(country_nid)
sum percentage
restore
//////////////////////////////
**Employer's association**
preserve
drop if missing(polexp)
gen temp=1
sort country_nid
by country_nid: egen employ=total(temp) if polexp==3
by country_nid: egen allexp=total(temp)
gen percentage=employ/allexp*100
keep if employ<.
duplicates drop country_nid, force
merge m:1 country_nid using  "Country_list.dta"
replace percentage=0 if _merge==2
sum percentage
return list
sum percentage if wealth==1
sum percentage if wealth==0
sum percentage if regime==0
sum percentage if regime==1
by region, sort: sum percentage
restore
*Apex* 
preserve
keep if power==1
gen temp=1
sort country_nid
by country_nid: egen employ=total(temp) if polexp==3
by country_nid: egen allexp=total(temp)
gen percentage=employ/allexp*100
replace percentage=0 if missing(percentage) 
collapse (max) percentage, by(country_nid)
sum percentage
restore
*Top ten*
preserve
keep if power==3
gen temp=1
sort country_nid
by country_nid: egen employ=total(temp) if polexp==3
by country_nid: egen allexp=total(temp)
gen percentage=employ/allexp*100
replace percentage=0 if missing(percentage) 
collapse (max) percentage, by(country_nid)
sum percentage
restore
*Cabinet*
preserve
keep if office1==2 |office2==2 |office3==2
gen temp=1
sort country_nid
by country_nid: egen employ=total(temp) if polexp==3
by country_nid: egen allexp=total(temp)
gen percentage=employ/allexp*100
replace percentage=0 if missing(percentage) 
collapse (max) percentage, by(country_nid)
sum percentage
restore
*Supreme Court*
preserve
keep if office1==7 |office2==7 |office3==7 
gen temp=1
sort country_nid
by country_nid: egen employ=total(temp) if polexp==3
by country_nid: egen allexp=total(temp)
gen percentage=employ/allexp*100
replace percentage=0 if missing(percentage) 
collapse (max) percentage, by(country_nid)
sum percentage
restore
*MPs*
preserve
keep if office1==6 |office2==6 |office3==6
gen temp=1
sort country_nid
by country_nid: egen employ=total(temp) if polexp==3
by country_nid: egen allexp=total(temp)
gen percentage=employ/allexp*100
replace percentage=0 if missing(percentage) 
collapse (max) percentage, by(country_nid)
sum percentage
restore
///////////////////////////////
**Interest group**
preserve
drop if missing(polexp)
gen temp=1
sort country_nid
by country_nid: egen interest=total(temp) if polexp==4
by country_nid: egen allexp=total(temp)
gen percentage= interest/allexp*100
keep if interest<.
duplicates drop country_nid, force
merge m:1 country_nid using  "Country_list.dta"
replace percentage=0 if _merge==2
sum percentage
return list
sum percentage if wealth==1
sum percentage if wealth==0
sum percentage if regime==0
sum percentage if regime==1
by region, sort: sum percentage
restore
*Apex* 
preserve
keep if power==1
gen temp=1
sort country_nid
by country_nid: egen interest=total(temp) if polexp==4
by country_nid: egen allexp=total(temp)
gen percentage=interest/allexp*100
replace percentage=0 if missing(percentage) 
collapse (max) percentage, by(country_nid)
sum percentage
restore
*Top ten*
preserve
keep if power==3
gen temp=1
sort country_nid
by country_nid: egen interest=total(temp) if polexp==4
by country_nid: egen allexp=total(temp)
gen percentage=interest/allexp*100
replace percentage=0 if missing(percentage) 
collapse (max) percentage, by(country_nid)
sum percentage
restore
*Cabinet*
preserve
keep if office1==2 |office2==2 |office3==2
gen temp=1
sort country_nid
by country_nid: egen interest=total(temp) if polexp==4
by country_nid: egen allexp=total(temp)
gen percentage=interest/allexp*100
replace percentage=0 if missing(percentage) 
collapse (max) percentage, by(country_nid)
sum percentage
restore
*Supreme Court*
preserve
keep if office1==7 |office2==7 |office3==7 
gen temp=1
sort country_nid
by country_nid: egen interest=total(temp) if polexp==4
by country_nid: egen allexp=total(temp)
gen percentage=interest/allexp*100
replace percentage=0 if missing(percentage) 
collapse (max) percentage, by(country_nid)
sum percentage
restore
*MPs*
preserve
keep if office1==6 |office2==6 |office3==6
gen temp=1
sort country_nid
by country_nid: egen interest=total(temp) if polexp==4
by country_nid: egen allexp=total(temp)
gen percentage=interest/allexp*100
replace percentage=0 if missing(percentage) 
collapse (max) percentage, by(country_nid)
sum percentage
restore
///////////////////////////////
**NGO**
preserve
drop if missing(polexp)
gen temp=1
sort country_nid
by country_nid: egen ngo=total(temp) if polexp==5
by country_nid: egen allexp=total(temp)
gen percentage=ngo/allexp*100
keep if ngo<.
duplicates drop country_nid, force
merge m:1 country_nid using  "Country_list.dta"
replace percentage=0 if _merge==2
sum percentage
return list
gen percentage1=r(sum)/144
sum percentage if wealth==1
sum percentage if wealth==0
sum percentage if regime==0
sum percentage if regime==1
by region, sort: sum percentage
restore
*Apex* 
preserve
keep if power==1
gen temp=1
sort country_nid
by country_nid: egen ngo=total(temp) if polexp==5
by country_nid: egen allexp=total(temp)
gen percentage=ngo/allexp*100
replace percentage=0 if missing(percentage) 
collapse (max) percentage, by(country_nid)
sum percentage
restore
*Top ten*
preserve
keep if power==3
gen temp=1
sort country_nid
by country_nid: egen ngo=total(temp) if polexp==5
by country_nid: egen allexp=total(temp)
gen percentage=ngo/allexp*100
replace percentage=0 if missing(percentage) 
collapse (max) percentage, by(country_nid)
sum percentage
restore
*Cabinet*
preserve
keep if office1==2 |office2==2 |office3==2
gen temp=1
sort country_nid
by country_nid: egen ngo=total(temp) if polexp==5
by country_nid: egen allexp=total(temp)
gen percentage=ngo/allexp*100
replace percentage=0 if missing(percentage) 
collapse (max) percentage, by(country_nid)
sum percentage
restore
*Supreme Court*
preserve
keep if office1==7 |office2==7 |office3==7 
gen temp=1
sort country_nid
by country_nid: egen ngo=total(temp) if polexp==5
by country_nid: egen allexp=total(temp)
gen percentage=ngo/allexp*100
replace percentage=0 if missing(percentage) 
collapse (max) percentage, by(country_nid)
sum percentage
restore
*MPs*
preserve
keep if office1==6 |office2==6 |office3==6
gen temp=1
sort country_nid
by country_nid: egen ngo=total(temp) if polexp==5
by country_nid: egen allexp=total(temp)
gen percentage=ngo/allexp*100
replace percentage=0 if missing(percentage) 
collapse (max) percentage, by(country_nid)
sum percentage
restore
///////////////////////////////////////////////////////////////
**Local government**
preserve
drop if missing(polexp)
gen temp=1
sort country_nid
by country_nid: egen local=total(temp) if polexp==6
by country_nid: egen allexp=total(temp)
gen percentage=local/allexp*100
keep if local<.
duplicates drop country_nid, force
merge m:1 country_nid using  "Country_list.dta"
replace percentage=0 if _merge==2
sum percentage
return list
sum percentage if wealth==1
sum percentage if wealth==0
sum percentage if regime==0
sum percentage if regime==1
by region, sort: sum percentage
restore
*Apex* 
preserve
keep if power==1
gen temp=1
sort country_nid
by country_nid: egen local=total(temp) if polexp==6
by country_nid: egen allexp=total(temp)
gen percentage=local/allexp*100
replace percentage=0 if missing(percentage) 
collapse (max) percentage, by(country_nid)
sum percentage
restore
*Top ten*
preserve
keep if power==3
gen temp=1
sort country_nid
by country_nid: egen local=total(temp) if polexp==6
by country_nid: egen allexp=total(temp)
gen percentage=local/allexp*100
replace percentage=0 if missing(percentage) 
collapse (max) percentage, by(country_nid)
sum percentage
restore
*Cabinet*
preserve
keep if office1==2 |office2==2 |office3==2
gen temp=1
sort country_nid
by country_nid: egen local=total(temp) if polexp==6
by country_nid: egen allexp=total(temp)
gen percentage=local/allexp*100
replace percentage=0 if missing(percentage) 
collapse (max) percentage, by(country_nid)
sum percentage
restore
*Supreme Court*
preserve
keep if office1==7 |office2==7 |office3==7 
gen temp=1
sort country_nid
by country_nid: egen local=total(temp) if polexp==6
by country_nid: egen allexp=total(temp)
gen percentage=local/allexp*100
replace percentage=0 if missing(percentage) 
collapse (max) percentage, by(country_nid)
sum percentage
restore
*MPs*
preserve
keep if office1==6 |office2==6 |office3==6
gen temp=1
sort country_nid
by country_nid: egen local=total(temp) if polexp==6
by country_nid: egen allexp=total(temp)
gen percentage=local/allexp*100
replace percentage=0 if missing(percentage) 
collapse (max) percentage, by(country_nid)
sum percentage
restore
/////////////////////////////////////////////////////////////////
**MP/Minister**
preserve
drop if missing(polexp)
gen temp=1
sort country_nid
by country_nid: egen mpmin=total(temp) if polexp==7
by country_nid: egen allexp=total(temp)
gen percentage=mpmin/allexp*100
keep if mpmin<.
duplicates drop country_nid, force
merge m:1 country_nid using  "Country_list.dta"
replace percentage=0 if _merge==2
sum percentage
return list
sum percentage if wealth==1
sum percentage if wealth==0
sum percentage if regime==0
sum percentage if regime==1
by region, sort: sum percentage
restore
*Apex* 
preserve
keep if power==1
gen temp=1
sort country_nid
by country_nid: egen mpmin=total(temp) if polexp==7
by country_nid: egen allexp=total(temp)
gen percentage=mpmin/allexp*100
replace percentage=0 if missing(percentage) 
collapse (max) percentage, by(country_nid)
sum percentage
restore
*Top ten*
preserve
keep if power==3
gen temp=1
sort country_nid
by country_nid: egen mpmin=total(temp) if polexp==7
by country_nid: egen allexp=total(temp)
gen percentage=mpmin/allexp*100
replace percentage=0 if missing(percentage) 
collapse (max) percentage, by(country_nid)
sum percentage
restore
*Cabinet*
preserve
keep if office1==2 |office2==2 |office3==2
gen temp=1
sort country_nid
by country_nid: egen mpmin=total(temp) if polexp==7
by country_nid: egen allexp=total(temp)
gen percentage=mpmin/allexp*100
replace percentage=0 if missing(percentage) 
collapse (max) percentage, by(country_nid)
sum percentage
restore
*Supreme Court*
preserve
keep if office1==7 |office2==7 |office3==7 
gen temp=1
sort country_nid
by country_nid: egen mpmin=total(temp) if polexp==7
by country_nid: egen allexp=total(temp)
gen percentage=mpmin/allexp*100
replace percentage=0 if missing(percentage) 
collapse (max) percentage, by(country_nid)
sum percentage
restore
*MPs*
preserve
keep if office1==6 |office2==6 |office3==6
gen temp=1
sort country_nid
by country_nid: egen mpmin=total(temp) if polexp==7
by country_nid: egen allexp=total(temp)
gen percentage=mpmin/allexp*100
replace percentage=0 if missing(percentage) 
collapse (max) percentage, by(country_nid)
sum percentage
restore
/////////////////////////////////////////////////////////////
//Partisan
preserve
drop if missing(polexp)
gen temp=1
sort country_nid
by country_nid: egen partisan=total(temp) if polexp==8
by country_nid: egen allexp=total(temp)
gen percentage=partisan/allexp*100
keep if partisan<.
duplicates drop country_nid, force
merge m:1 country_nid using  "Country_list.dta"
replace percentage=0 if _merge==2
sum percentage
return list
sum percentage if wealth==1
sum percentage if wealth==0
sum percentage if regime==0
sum percentage if regime==1
by region, sort: sum percentage
restore
*Apex* 
preserve
keep if power==1
gen temp=1
sort country_nid
by country_nid: egen partisan=total(temp) if polexp==8
by country_nid: egen allexp=total(temp)
gen percentage=partisan/allexp*100
replace percentage=0 if missing(percentage) 
collapse (max) percentage, by(country_nid)
sum percentage
restore
*Top ten*
preserve
keep if power==3
gen temp=1
sort country_nid
by country_nid: egen partisan=total(temp) if polexp==8
by country_nid: egen allexp=total(temp)
gen percentage=partisan/allexp*100
replace percentage=0 if missing(percentage) 
collapse (max) percentage, by(country_nid)
sum percentage
restore
*Cabinet*
preserve
keep if office1==2 |office2==2 |office3==2
gen temp=1
sort country_nid
by country_nid: egen partisan=total(temp) if polexp==8
by country_nid: egen allexp=total(temp)
gen percentage=partisan/allexp*100
replace percentage=0 if missing(percentage) 
collapse (max) percentage, by(country_nid)
sum percentage
restore
*Supreme Court*
preserve
keep if office1==7 |office2==7 |office3==7 
gen temp=1
sort country_nid
by country_nid: egen partisan=total(temp) if polexp==8
by country_nid: egen allexp=total(temp)
gen percentage=partisan/allexp*100
replace percentage=0 if missing(percentage) 
collapse (max) percentage, by(country_nid)
sum percentage
restore
*MPs*
preserve
keep if office1==6 |office2==6 |office3==6
gen temp=1
sort country_nid
by country_nid: egen partisan=total(temp) if polexp==8
by country_nid: egen allexp=total(temp)
gen percentage=partisan/allexp*100
replace percentage=0 if missing(percentage) 
collapse (max) percentage, by(country_nid)
sum percentage
restore
